package com.longge;

import java.util.HashSet;

public class NumDifferentIntegers {

    public int numDifferentIntegers(String word) {

        char[] chars = word.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            if (Character.isLetter(chars[i])) {
                chars[i] = ' ';
            }
        }
        String[] strs = new String(chars).split(" ");
        HashSet<String> set = new HashSet<>();
        for (String str : strs) {
            if (!str.equals(" ") && !str.equals("")) {
                int i = 0;
                while (i < str.length() && str.charAt(i) == '0') {
                    i++;
                }
                if (i == str.length()) {
                    set.add("0");
                } else if (i != 0) {
                    set.add(str.substring(i));
                } else {
                    set.add(str);
                }
            }
        }
        return set.size();
    }
}
